home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / ghostscript / 8.64 / Resource / Init / gs_cidfm.ps < prev    next >
Encoding:
Text File  |  2009-04-17  |  4.5 KB  |  130 lines

  1. %    Copyright (C) 2000 Artifex Software, Inc.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_cidfm.ps 8954 2008-08-08 04:22:38Z ray $
  14. % Redefine CIDFont category with cidfmap .
  15.  
  16. languagelevel 2 .setlanguagelevel
  17.  
  18. 4 dict begin
  19. /CategoryName /CIDFont def
  20.  
  21. /MapFileName (cidfmap) def
  22.  
  23. /IsMyRecord      % <raw_record> -> <raw_record> bool
  24. { % Only for client's needs.
  25.   dup type /nametype eq
  26. } bind def
  27.  
  28. /RecordVirtualMethods 3 dict begin
  29.  
  30.   /MakeInstance   % <Name> <record> MakeInstance <Name> <Instance> <size>
  31.   { % We know that currentdict is the category.
  32.     /Substitute get FindResource            % /Name <<CIDFont>>
  33.     dup length dict copy                    % /Name <<CIDFont>>
  34.     1 index ResourceStatus pop exch pop     % /Name <<CIDFont>> size
  35.   } bind def
  36.  
  37.   /GetFilePath  % <scratch> <Name> <record> GetFilePath <filepath>
  38.   { % We know that currentdict is the category.
  39.     exch pop
  40.     /Substitute get exch ResourceFileName
  41.   } bind def
  42.  
  43.   /GetSize   % <Name> <record> GetSize <size>
  44.   { % We know that currentdict is the category.
  45.     /Substitute get ResourceStatus {
  46.       exch pop exch pop
  47.     } {
  48.       /undefinedresource signalerror
  49.     } ifelse
  50.   } bind def
  51.  
  52.   /GetCSI   % <record> GetCSI null
  53.           % <record> GetCSI dict
  54.   { % We know that currentdict is the category.
  55.     RESMPDEBUG { (cidfm GetCSI beg ) = } if
  56.     /Substitute get            % /Name
  57.     GetCIDSystemInfoFromMap
  58.     RESMPDEBUG { (cidfm GetCSI end ) print dup = } if
  59.   } bind def
  60.  
  61.   /IsActive % <record> IsActive <bool>
  62.   { pop true
  63.   } bind def
  64.  
  65. currentdict end def
  66.  
  67. /VerifyMap  % <raw_map> VerifyMap -
  68. { % Checks for vicious substitution cycles.
  69.   dup length dict copy                  % <<map>>
  70.   dup length dict                       % <<map>> <<temp>>
  71.   { % Choose a random record :
  72.     true 2 index {                      % <<map>> <<temp>> true /Name /Subs
  73.       3 2 roll pop false exit           % <<map>> <<temp>> /Name /Subs false
  74.     } forall
  75.     { exit                              % <<map>> <<temp>>
  76.     } if                                % <<map>> <<temp>> /Name /Subs
  77.     % Move the substitution chain to <<temp>>, checking for a cycle :
  78.     3 index 2 index undef               % <<map>> <<temp>> /Name /Subs
  79.     exch 2 index exch 0 put             % <<map>> <<temp>> /Subs
  80.     { //IsMyRecord exec not {
  81.         % Not a substitution, the chain terminates.
  82.         pop exit                        % <<map>> <<temp>>
  83.       } if                              % <<map>> <<temp>> /Subs
  84.       1 index 1 index known {
  85.         (Vicious substitution cycle in map file with the entry ) print =string cvs print ( .) =
  86.         /VerifyMap cvx /undefinedresource signalerror
  87.       } if                              % <<map>> <<temp>> /Subs
  88.       1 index 1 index 0 put
  89.       dup 3 index exch .knownget not {  % <<map>> <<temp>> /Subs
  90.         % No more substitutions, the chain terminates.
  91.         pop exit                        % <<map>> <<temp>>
  92.       } if                              % <<map>> <<temp>> /Subs /Subs1
  93.       exch                              % <<map>> <<temp>> /Subs1 /Subs
  94.       3 index exch undef                % <<map>> <<temp>> /Subs1
  95.     } loop
  96.     % Not cycled, now purge the <<temp>> :
  97.     { % Choose a random record :
  98.       true 1 index {                    % <<map>> <<temp>> true /Name /Subs
  99.         3 2 roll pop false exit         % <<map>> <<temp>> /Name /Subs false
  100.       } forall
  101.       { exit                            % <<map>> <<temp>>
  102.       } if                              % <<map>> <<temp>> /Name /Subs
  103.       % Remove it :
  104.       pop 1 index exch undef            % <<map>> <<temp>>
  105.     } loop
  106.   } loop
  107.   pop pop                               %
  108. } bind def
  109.  
  110. /PreprocessRecord  % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  111. { //IsMyRecord exec {
  112.     1 dict begin
  113.     /Substitute exch def
  114.     /RecordVirtualMethods //RecordVirtualMethods def
  115.     currentdict end
  116.     true
  117.   } {
  118.     false
  119.   } ifelse
  120. } bind def
  121.  
  122. currentdict end 
  123.  
  124. /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
  125.  
  126. .setlanguagelevel
  127.